/**
 * 入院管理模块 hspt_live_in_manege.jsp
 */

/**
 * 打开打印入院登记窗口
 */
function openWindowPrintLiveIn() {
	$('#WindowPrintLiveIn').window('open');
}

/**
 * 打开查看详情窗口
 */
function onBookPatient(index) {
	
	$('#live_in_manage_table').datagrid('selectRow',index);
	var row = $('#live_in_manage_table').datagrid('getSelected');

	$('#windowPatientQuery').window({
		href:'to_hspt_live_patientInfo',
		queryParams:{
			"liveID":row.liveid8
		}
	});
	$('#windowPatientQuery').window('open');
}
/**
 *  初始化详情窗口
 */
function initwindowPatientQuery(){
	var liveid = $('#displayLiveID').val();
	$('#patientInfo_visitor_Table').datagrid({
		url:'to_queryvisitorByLiveID',
		queryParams:{
			"liveID":liveid
		}
	});
	$('#patientInfo_yajinTable').datagrid({
		url:'to_queryDepositByLiveID',
		queryParams:{
			"liveID":liveid
		}
	});
	$('#patientInfo_feesTable').datagrid({
		url:'to_queryTallyByLiveID',
		queryParams:{
			"liveID":liveid
		}
	});
	$('#patientInfo_payTable').datagrid({
		url:'to_queryPayByLiveID',
		queryParams:{
			"liveID":liveid
		}
	});
}

/**
 * 打开访客查询面板
 */
function openWindowVisiterQuery() {
	$('#windowVisiterQuery').window('open');
}

/**
 * 初始化探望查询表
 */
function initVisitorTable(){
	var  starDate = $('#visitor_query_startDate').datebox('getValue');
	var  endDate = $('#visitor_query_endDate').datebox('getValue');
	
	$('#visitor_query_Table').datagrid({
		url:'to_fuzzyqueryvisitor',
		queryParams : {
			"starDate" : starDate,
			"endDate" : endDate
		}
	});
}


/**
 * 根据日期查询探望
 * @param index
 */
function initVisitorTableByDate(){
	var  starDate = $('#visitor_query_startDate').datebox('getValue');
	var  endDate = $('#visitor_query_endDate').datebox('getValue');
	if(starDate !='' && endDate !='' && starDate<endDate){
		initVisitorTable();
	}else{
		$.messager.alert('警告！','日期选择有误，请重新选择!','warning');
	}
}
/**
 * 查询全部探望
 */
function initVisitorAll(){
	$('#visitor_query_startDate').datebox('setValue',null);
	$('#visitor_query_endDate').datebox('setValue',null);
	initVisitorTable();
}

/**
 * 打开新增访客窗口
 */
function onAddVisiter(index) {
	$('#live_in_manage_table').datagrid('selectRow',index);
	var row = $('#live_in_manage_table').datagrid('getSelected');
	$('#visiterpage_patientname').textbox('setValue',row.patientname8);
	$('#visiterpage_liveInId').textbox('setValue',row.liveid8);
	$('#windowAddVisiter').window('open');	
}
/**
 * 初始化探望ID
 */
function initVisitorID() {
	
	$.getJSON("to_initVisitorID", {},
			  function(data){
		        $('#visiterpage_visitid').textbox('setValue',data.VisitID);
			  }); 
}

/**
 * 提交新增探望记录表单
 */
function onSubmitAddVisiterFrom(){
	var data = $('#visiterpage_visittime').datebox('getValue');
	$('#from_visitor_add').form({
		 url: "to_visitor_add",
		 onSubmit:function(param){
			var liveID = $('#visiterpage_liveInId').textbox('getValue');
			param.liveInID = liveID;
			return $('#from_visitor_add').form("validate");
		},
		success:function(v){
			$('#from_visitor_add').form("reset");
			$('#windowAddVisiter').window('close');
		}
	});
	$('#from_visitor_add').submit();
}
/**
 * 根据姓名模糊查询住院病人**************************
 * ***********************
 */
function queryLiveLivePatient(){

	var likePname = $('#live_in_manage_name').val();
	if(likePname !=''){
		$('#live_in_manage_table').datagrid({          
			url : "to_fuzzyQueryLiveIn",
			queryParams: {
				"likename" : likePname                     
			}
		});
	}
}
//查询全部病人
function queryALLpatient(){
	$('#live_in_manage_office').combobox('setValue',null);
	$('#live_in_manage_afterdate').combobox('setValue',null);
	$('#live_in_manage_beforedate').combobox('setValue',null);
	$('#live_in_manage_sex').combobox('setValue',null);
}
//动态查询住院病人
function dynamicqueryLivePatient(){
	var liveoffice4 = $('#live_in_manage_office').combobox('getValue');
	var afterLivedate = $('#live_in_manage_afterdate').combobox('getValue');
	var beforeLivedate = $('#live_in_manage_beforedate').combobox('getValue');
	var patientsex = $('#live_in_manage_sex').combobox('getValue');
	$('#live_in_manage_table').datagrid({
		url:"to_dynamicQueryLiveIn",
		queryParams:{
			"liveoffice4":liveoffice4,
			"afterLivedate":afterLivedate,
			"beforeLivedate":beforeLivedate,
			"patientsex":patientsex
		}		
	});
}
/**
 * 验证截止日期大于开始日期验证
 */
function checkDateSelect(){
	var starDate =  $('#live_in_manage_afterdate').datebox('getValue');
	var endDate  =  $('#live_in_manage_beforedate').datebox('getValue');
	if(starDate ==''||endDate ==''){
		dynamicqueryLivePatient();
	}else{
		if(starDate<endDate){
			dynamicqueryLivePatient();
		}else{
			$.messager.alert('警告','前后日期选择冲突!','warning');
		}
	}
}

/**
 * 新增入院登记界面 hspt_live_in_add.jsp
 */
/**
 * 打开新增入院登记窗口
 */
function openWindowAddLiveIn() {
	$('#windowAddLineIn').window('open');
	createLiveID();
}
/**
 * 初始化住院号
 */
function createLiveID(){
	
	$.getJSON("to_new_hspt_createLiveID", {},
			  function(data){
		        $('#liveAddInitID').textbox('setValue',data);
			  }); 
}
/**
 *提交新增入院表单
 */
function addLiveInRecode(){
	var name1 = $("#DisReturnMZnumber").val();
	var name2 = $("#Returnpatientname8").textbox('getValue');
	if(name1!=name2){
		$.messager.alert('提示','诊疗卡与住院通知信息不符，请重新选择！','info');
	}else{
		var despoit = $("#liveInAddDeposit").textbox('getValue');
		var DoctorID = $("#liveInAddStaffID").val();
		var MedicalId = $("#ReturncradId").textbox('getValue');
		var BedId = $("#ReturnBedDisplayID").val();

		$("#addLiveInForm").form({
			url:'to_AddLiveInRecode',
			onSubmit:function(Param){
				Param.despoit = despoit;
				Param.DoctorID = DoctorID;
				Param.MedicalId = MedicalId;
				Param.BedId = BedId;
				return $('#addLiveInForm').form("validate");
			},
			success:function(v){
				if(v=true){
					$('#addLiveInForm').form("reset");
					$('#windowAddLineIn').window('close');
					$.messager.alert('提示','操作成功！','info');
					$('#live_in_manage_table').datagrid('reload');
				}
				
			}
		});
		$('#addLiveInForm').submit();
	}
}

/**
 * 创建住院通知查询窗口
 */
var QueryLiveInNoticWindow;
function createQueryLiveInNoticWindow(){
	QueryLiveInNoticWindow = $("<div/>").window({
		title:'住院通知查询',
		href:'to_hspt_live_In_notic',
		width:800,
		height:350,
		modal:true,
		collapsible:false,
		minimizable:false,
		maximizable:false,
		resizable:false,
		iconCls:'icon-search',
		onClose:function(){
			$(this).window('destroy');
		},
		onLoad:function(){}
	});
}

/**
 * 根据姓名模糊查询住院通知
 */
function queryLiveNotic(){
	var likePname = $('#noticNameLikeinput').val();
	if(likePname!=''){
		$('#live_notic_inform_table').datagrid({          
			url : "to_queryLikeNotic",
			queryParams: {
				"likePname" : likePname                     
			}
		});
	}
}
/**
 * 将选中的住院通知信息读取出来回填到住院登记表单
 */
function selectinfo() {
	var selected = $('#live_notic_inform_table').datagrid('getSelected');
	
	if (selected != null) {
		$('#DisReturnMZnumber').val(selected.PATIENTNAME);
		$('#Returnlivenoticid3').textbox('setValue', selected.LIVENOTICID);//住院通知号
		$('#ReturnMZnumber').textbox('setValue', selected.PATIENT_REGISTRATION_ID);//门诊号
		$('#Returnmjdoctorname').textbox('setValue', selected.MJDOCTORNAME);//门诊医生
		QueryLiveInNoticWindow.window('destroy');
	}
}

/**
 * 创建诊疗卡查询窗口
 */
var WindowQueryMediaclQuery;
function CreateWindowQueryMediaclQuery(){
	WindowQueryMediaclQuery = $("<div/>").window({
		title:'诊疗卡查询',
		href:'to_Medical_queryWindow',
		width:850,
		height:350,
		modal:true,
		collapsible:false,
		minimizable:false,
		maximizable:false,
		resizable:false,
		iconCls:'icon-search',
		onClose:function(){
			$(this).window('destroy');
		},
		onLoad:function(){}
	});
}
/**
 * 根据姓名模糊查询诊疗卡
 */
function likeQueryMediaclCardByName(){

	var likeCname = $('#MediaclCardNameLikeinput').val();
	if(likeCname!=''){
		$('#live_MediaclCard_inform_table').datagrid({          
			url : "to_Medical_queryLikeName",
			queryParams: {
				"likename" : likeCname                     
			}
		});
	}
}
/**
 * 根据ID模糊查询诊疗卡
 */
function likeQueryMediaclCardById(){

	var likeID= $('#MediaclCardIDLikeinput').val();
	if(likeID!=''){
		$('#live_MediaclCard_inform_table').datagrid({          
			url : "to_Medical_queryLikeID",
			queryParams: {
				"likeID" : likeID                     
			}
		});
	}
}
/**
 * 将选中的诊疗卡信息读取出来回填到住院登记表单
 */
function selectMediaclCardinfo() {
	var selected = $('#live_MediaclCard_inform_table').datagrid('getSelected');
	
	if (selected != null) {
		$('#ReturncradId').textbox('setValue', selected.cradId);//卡号
		$('#Returnpatientname8').textbox('setValue', selected.name);//姓名
		$('#Returnpatientsex').textbox('setValue', selected.sex);//性别
		$('#Returnpatientage').textbox('setValue', selected.age);//年龄
		$('#Returnidcard').textbox('setValue', selected.idCard);//身份证
		$('#Returnpatientloc').textbox('setValue', selected.address);//地址
		WindowQueryMediaclQuery.window('destroy');
	}
}
/**
 * 创建主治医生查询窗口
 */ 
var WindowQueryLiveDoctor;
function createWindowQueryLiveDoctor() {
	WindowQueryLiveDoctor = $("<div/>").window({
		title:'主治医生选择',
		href:'to_hspt_Doctor_quary',
		width:650,
		height:550,
		modal:true,
		collapsible:false,
		minimizable:false,
		maximizable:false,
		resizable:false,
		iconCls:'icon-search',
		onClose:function(){
			$(this).window('destroy');
		},
		onLoad:function(){}
	});
	$("#DoctorSelect").window("options").SelectDoctor = "toliveInAdd";
}
/**
 * 动态查询主治医生
 */
function fuzzyQueryDoctor(){
	var officeName = $("#doctorQuery_OfficeName").combotree('getValue');
	var dutyName = $("#doctorQuery_DutyName").combobox('getValue');
	var DoctorName = $("#doctorQuery_DoctorName").textbox('getValue');
	
	$("#live_DoctorQuery_inform_table").datagrid({
		url:'to_hspt_live_fuzzyfineDoctor',
		queryParams:{
			"officeName":officeName,
			"dutyName":dutyName,
			"DoctorName":DoctorName
		}
	});
}
/**
 * 清空条件
 */
function ClearfuzzyQueryDoctor(){
	$("#doctorQuery_OfficeName").combotree('clear');
	$("#doctorQuery_DutyName").combobox('clear');
	$("#doctorQuery_DoctorName").textbox('clear');
}
/**
 * 回填医生信息判断
 */
function returnDoctorInfoDecide(){
	var s = $("#DoctorSelect").window("options").SelectDoctor;
	if(s=='toliveInAdd'){
		returnDoctorInfoToAdddLiveIN();
	}else{
		
	}
	WindowQueryLiveDoctor.window('destroy');
}
/**
 * 回填医生信息至增加入院登记
 */
function returnDoctorInfoToAdddLiveIN(){
	var row = $("#live_DoctorQuery_inform_table").datagrid('getSelected');
	$("#liveInAddStaffname").textbox('setValue',row.DOCTOTNAME);
	$("#liveInAddStaffID").val(row.DOCTORID);
}
/**
 * 动态查询住院押金
 */
function fuzzyInitDeposit(){
	var depositstatus =$('#fuzzyFinddeposit_Status').combobox('getValue');
	var afterLivedate =$('#fuzzyFinddeposit_afterTime').combobox('getValue');
	var beforeLivedate =$('#fuzzyFinddeposit_beforeTime').combobox('getValue');
	
	$('#fuzzyFinddeposit_Table').datagrid({
		url:'to_fuzzyqueryDepositt',
		queryParams:{
			"depositstatus":depositstatus,
			"afterLivedate":afterLivedate,
			"beforeLivedate":beforeLivedate
		}
	});
}
/**
 * 判断选择日期后索搜
 */
function fuzzysearchDeposit(){
	var starDate =  $('#fuzzyFinddeposit_afterTime').datebox('getValue');
	var endDate  =  $('#fuzzyFinddeposit_beforeTime').datebox('getValue');
	if(starDate ==''||endDate ==''){
		fuzzyInitDeposit();
	}else{
		if(starDate<endDate){
			fuzzyInitDeposit();
		}else{
			$.messager.alert('警告','前后日期选择冲突!','warning');
		}
	}
}



/**
 * 收取押金
 * @param index
 */
function chargeDeposit(index){
	$("#fuzzyFinddeposit_Table").datagrid('selectRow',index);
	var row = $('#fuzzyFinddeposit_Table').datagrid('getSelected');
	
	if(row.depositstatus=="未缴"){
		$("#windowchargeDeposit").window('open');
		$("#chargeDepositID").textbox('setValue',row.depositid2);
		$("#chargeDepositName").textbox('setValue',row.patientname5);
		$("#chargeDepositAmount").textbox('setValue',row.depositlimit4);
	}else{
		$.messager.alert('提示','此押金已处理，操作无效！','info');
	}
}
/**
 * 提交 chargeDepositForm 
 */
function onSubmitchargeDepositForm(){
	$("#chargeDepositForm").form({
		url:'to_chargedeposit',
		onSubmit:function(param){
			return $('#chargeDepositForm').form("validate");
		},
		success:function(v){
			$('#chargeDepositForm').form("reset");
			$('#windowchargeDeposit').window('close');
			$("#fuzzyFinddeposit_Table").datagrid('reload');
		}
	});
	$("#chargeDepositForm").submit();
	
}
/**
 * 退还押金
 * @param index
 */
function returnDeposit(index){
	$("#fuzzyFinddeposit_Table").datagrid('selectRow',index);
	var row = $('#fuzzyFinddeposit_Table').datagrid('getSelected');
	
	if(row.depositstatus=="已缴"){
		$("#windowReturnDeposit").window('open');
		
		$("#ReturnDepositLiveID").textbox('setValue',row.liveid5);
		$("#ReturnDepositID").textbox('setValue',row.depositid2);
		$("#ReturnDepositName").textbox('setValue',row.patientname5);
		$("#ReturnDepositAmount").textbox('setValue',row.depositlimit4);
	}else{
		$.messager.alert('提示','此押金已处理，操作无效！','info');
	}
	
}
/**
 * 动态查询退还押金
 */
function fuzzyqueryReturnDeposit(){
	var afterTime = $("#fuzzyFindReturndeposit_afterTime").datebox('getValue');
	var beforeTime = $("#fuzzyFindReturndeposit_beforeTime").datebox('getValue');
	
	if(afterTime==""||beforeTime==""){
		$("#fuzzyFindRetuendeposit_Table").datagrid({
			url:'to_fuzzyQueryReturnDeposit',
			queryParams:{
				"afterTime":afterTime,
				"beforeTime":beforeTime
			}
		});
	}else{
		if(afterTime<beforeTime){
			$("#fuzzyFindRetuendeposit_Table").datagrid({
				url:'to_fuzzyQueryReturnDeposit',
				queryParams:{
					"afterTime":afterTime,
					"beforeTime":beforeTime
				}
			});
		}else{
			$.messager.alert('提示','日期选择有误！','info');
		}
	}
}
/**
 * 提交新增退还押金表单
 */
function onSubmitReturnDepositFrom(){
	$("#returnDepositForm").form({
		url:'to_addReturnDeposit',
		onSubmit:function(param){
			return $('#returnDepositForm').form("validate");
		},
		success:function(v){
			$('#returnDepositForm').form("reset");
			$('#windowReturnDeposit').window('close');
			$("#fuzzyFinddeposit_Table").datagrid('reload');
		}
	});
	$('#returnDepositForm').submit();
}

/**
 * 初始化押金退还ID
 */
function initReturnDepositID() {
	
	$.getJSON("to_initReturnDepositID", {},
			  function(data){
		        $('#ReturnDepositReturnID').textbox('setValue',data.ReturnID);
			  }); 
}


/**
 * 催收押金
 * @param index
 */
function urgeDeposit(index){
	$("#fuzzyFinddeposit_Table").datagrid('selectRow',index);
	var row = $('#fuzzyFinddeposit_Table').datagrid('getSelected');
	
	if(row.depositstatus=="未缴"){
		$('#windowUrgeDeposit').window('open');
		
		$("#urgeDepositAmount").textbox('setValue',row.depositlimit4);
		$("#urgeDepositLiveID").textbox('setValue',row.liveid5);
		$("#urgeDepositOffice").textbox('setValue',row.liveoffice4);
		$("#urgeDepositName").textbox('setValue',row.patientname5);
		$("#urgeDepositToAmount").textbox('setValue',row.depositlimit4);
	}else{
		$.messager.alert('提示','此押金已处理，操作无效！','info');
	}
	
}
/**
 * 初始化催费单号
 */
function initUrgeDepositID(){
	$.getJSON('to_initUrgeDepositID',{},
			function(data){
		$('#urgeDepositID').textbox('setValue',data.UrgeDepositID);
	});
}
/**
 * 提交催费押金表单
 */
function onSubmitUrgeDepositForm(){
	$('#UrgeDepositForm').form({
		url:'to_addUrgeDeposit',
		onSubmit:function(param){
			return $('#UrgeDepositForm').form("validate");
		},
		success:function(v){
			$('#UrgeDepositForm').form("reset");
			$('#windowUrgeDeposit').window('close');
			$("#fuzzyFinddeposit_Table").datagrid('reload');
		}
	});
	$('#UrgeDepositForm').submit();
}

/**
 * 动态查询催费押金
 */
function fuzzyqueryUrgeDeposit(){
	var afterTime = $("#fuzzyFindUrgedeposit_afterTime").datebox('getValue');
	var beforeTime = $("#fuzzyFindUrgeposit_beforeTime").datebox('getValue');
	
	if(afterTime==""||beforeTime==""){
		$("#fuzzyFindUrgedeposit_Table").datagrid({
			url:'to_fuzzyQueryUrgeDeposit',
			queryParams:{
				"afterTime":afterTime,
				"beforeTime":beforeTime
			}
		});
	}else{
		if(afterTime<beforeTime){
			$("#fuzzyFindUrgedeposit_Table").datagrid({
				url:'to_fuzzyQueryUrgeDeposit',
				queryParams:{
					"afterTime":afterTime,
					"beforeTime":beforeTime
				}
			});
		}else{
			$.messager.alert('提示','日期选择有误！','info');
		}
	}
}
/**
 * 创建出院通知查询窗口
 */
var  LiveOutNoticPageWindow;
function createLiveOutNoticPage(){
	LiveOutNoticPageWindow = $("<div/>").window({
		title:'出院通知查询',
		href:'to_hspt_live_out_notic',
		width:850,
		height:400,
		modal:true,
		collapsible:false,
		minimizable:false,
		maximizable:false,
		resizable:false,
		iconCls:'icon-search',
		onClose:function(){
			$(this).window('destroy');
		},
		onLoad:function(){}
	});
}
/**
 * 根据姓名模糊查询出院通知
 */
function queryLiveOutNoticByLikeName(){
	var likeName = $("#LiveOutNoticNameLikeinput").val();
	if(likeName!=""){
		$("#live_Outnotic_inform_table").datagrid({
			url:'to_queryLiveOutNoticByLikeName',
			queryParams:{
				"likeName":likeName
			}
		});
	}
}
/**
 * 回填信息至
 */
function returnOutInfoToLiveOut(){
	var row = $('#live_Outnotic_inform_table').datagrid('getSelected');
	if(row!=''){
		$("#liveOut_outNoticID").textbox('setValue',row.outnoticid);
		$("#liveOut_LiveID").textbox('setValue',row.liveid);
		$("#liveOut_liveName").textbox('setValue',row.patientname);
		$("#liveOut_docname").textbox('setValue',row.doctor);
		$("#liveOut_outType").textbox('setValue',row.outtype);
		
		$.getJSON('to_returnLiveOutInfo',{"liveID":row.liveid},
				function(info){
			$("#liveOut_allspend").textbox('setValue',info.alltally);
			$("#liveOut_nopay").textbox('setValue',info.nopay);
			$("#liveOut_tel").textbox('setValue',info.tel);
			$("#liveOut_office").textbox('setValue',info.office);
			$("#liveOut_MZID").textbox('setValue',info.MZnumner);
			
			var bedStatus = info.bedStatus;
			$("#liveOut_bedStatus").textbox('setValue',bedStatus);
			var depositStatus = info.DepositIDStatus;
			$("#liveOut_depositStatus").textbox('setValue',depositStatus);
			
			if(info.nopay==0){
				$("#liveOut_feesStatus").textbox('setValue',"已结清");
			}else{
				$("#liveOut_feesStatus").textbox('setValue',"未结清");
			}
			if(depositStatus=='未退'||nopay!=0){
				$.messager.alert('提示','该账户异常，暂时不能出院！','info');
			}
		});
		
		$('#liveOut_tallyTable').datagrid({
			url:'to_queryTallyByLiveID',
			queryParams:{
				"liveID":row.liveid
			}
		});
		$('#liveOut_payTable').datagrid({
			url:'to_queryPayByLiveID',
			queryParams:{
				"liveID":row.liveid
			}
		});
	}
	LiveOutNoticPageWindow.window('destroy');
}
/**
 * 创建出院ID
 */
function createLiveOutId(){
	$.getJSON('to_returnLiveOutID',{},function(v){
		$("#liveOut_outID").textbox('setValue',v);
		});
}
/**
 * 清除新建
 */

function clearLiveOut(){
	$("#liveOut_form").form('reset');
	createLiveOutId();
	
	var rows1 = $('#liveOut_tallyTable').datagrid('getRows');//删除datagrid数据
    if(rows1!=''){
    	for(var i=rows1.length-1;i>=0;i--){
    	    	$("#liveOut_tallyTable").datagrid('deleteRow',i);
    	 }
    }
    var rows2 = $('#liveOut_payTable').datagrid('getRows');//删除datagrid数据
    if(rows2!=''){
    	for(var i=rows2.length-1;i>=0;i--){
    	    	$("#liveOut_payTable").datagrid('deleteRow',i);
    	 }
    }
}
/**
 * 提交表单
 */
function submitLiveOutFrom(){
	var nid = $("#liveOut_outNoticID").textbox('getValue');
	if(nid==""){
		$.messager.alert('提示','非法操作！','info');
	}else{
		var depositStatus= $("#liveOut_depositStatus").textbox('getValue');
		var payStatus= $("#liveOut_feesStatus").textbox('getValue');
		if(depositStatus=='已退'&&payStatus=='已结清'){
			$("#liveOut_form").form({
				success:function(v){
					if(v=true){
						clearLiveOut();
						$.messager.alert('提示','操作成功！！','info');
					}else{
						$.messager.alert('提示','操作失败！！','info');
					}
				}
			});
			$("#liveOut_form").submit();
		}else{
			$.messager.alert('提示','该病人住院状态异常，不能出院！！','info');
		}
	}
}
/**
 * 判断床位信息回填至哪里
 */
function decideReturnSickRoomInfoToWhere(){
	var sir = $("#SickRoomSelect").window("options").SelectSickRoom;
	if(sir == "toliveInAdd"){
		selectBEDinfo();
	}else if(sir == "toExchangeBed"){
		selectBEDinfoToexchange();
	}
}
/**
 * 打开病房查询面板
 */
var WindowQuerySickRoom;
function CreateWindowQuerySickRoom(){
	WindowQuerySickRoom=$('<div/>').window({
		title:'选择病房',
		href:'to_selectSickRoomWindow',
		width:900,
		height:500,
		modal:true,
		collapsible:false,
		minimizable:false,
		maximizable:false,
		resizable:false,
		iconCls:'icon-search',
		onClose:function(){
			$(this).window('destroy');
		},
		onLoad:function(){}
	});
	$("#SickRoomSelect").window("options").SelectSickRoom = "toliveInAdd";
}
/**
 * 将选中病床信息读取出来回填到住院登记表单
 */
function selectBEDinfo() {
	var selected = $('#bed_query_table2').datagrid('getSelected');
	if (selected != null) {
		$("#ReturnBedDisplayID").val(selected.BEDID);
		$('#ReturnBuildName').textbox('setValue', selected.BNAME);//楼号
		$('#ReturnFloorName').textbox('setValue', selected.FNAME);//楼层
		$('#ReturnRoomName').textbox('setValue', selected.SICKROOMNAME);//房间
		$('#ReturnBedName').textbox('setValue', selected.BEDNAME + '号床');//床位
		WindowQuerySickRoom.window('destroy');
	}
}
/**
 * 自定义验证规则
 */
$(function() {
	$.extend($.fn.validatebox.defaults.rules, {
		phone : {
			validator : function(value, param) {
				return /^(?:13\d|15\d|18\d)-?\d{5}(\d{3}|\*{3})$/.test(value);
			},
			message : '手机号码格式不正确'
		}
	})
})


